package com.gbb.simple.ui.animation;

import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.gbb.simple.base.BaseFragmentActivity;
import com.gbb.simple.R;

/**
 * @author gaobingbing on 2016/8/20.
 */
public class AnimActivity extends BaseFragmentActivity implements View.OnClickListener {


    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.anim_activity);

        textView = (TextView)findViewById(R.id.textView);

        findViewById(R.id.btn_anim).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch(v.getId()) {

            case R.id.btn_anim:
                float curX = textView.getTranslationX();
                ObjectAnimator animator = ObjectAnimator.ofFloat(textView,"translationX");
                animator.setFloatValues(curX,-500f,curX);
                animator.setDuration(6000);
                animator.start();
                break;
                
            default:
                break;
        }
    }
}
